package learning.randomAccessFile;

import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.util.RandomAccess;

public class RandomAccessFile1 {
	public static void main(String[] args) {
		RandomAccessFile raf = null;
		RandomAccessFile raf2 = null;
		try {
			raf = new RandomAccessFile("myfile/me.txt", "rw");
			raf.writeChars("I come from China!");
			raf.close();
			raf2 = new RandomAccessFile("myfile/me.txt", "rw");
			int b=0;
			while((b=raf2.read())!=-1){
				System.out.print((char)b);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
